package com.xwj.back.controller;

import com.alibaba.fastjson2.JSONObject;
import com.alibaba.fastjson2.TypeReference;
import com.xwj.back.pojo.Menu;
import com.xwj.back.pojo.Role;
import com.xwj.back.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
public class RoleController {

    @Autowired
    private RoleService roleService;

    @GetMapping("/role/getAll/")
    public List<Role> getRoleAll(@RequestParam("role") String role){
        return roleService.getRoleAll(role);
    }

    @PostMapping("/role/add/")
    public Map<String,String> addRole(@RequestBody Map<String,String> data){
        return roleService.addRole(data);
    }

    @PostMapping("/role/update/")
    public Map<String,String> updateRole(@RequestBody Map<String,String> data){
        return roleService.updateRole(data);
    }

    @PostMapping("/role/delete/")
    public Map<String,String> deleteRole(@RequestBody Map<String,String> data){
        return roleService.deleteRole(data);
    }

    //获取不同角色的菜单树
    @PostMapping("/role/menu/")
    public List<Menu> getMenuTree(@RequestBody Map<String,String> data){
        return roleService.getMenuTree(data);
    }
}
